package com.haust.su.ghyy.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.haust.su.ghyy.cmn.mapper.DictMapper;
import com.haust.su.ghyy.model.cmn.Dict;
import com.haust.su.ghyy.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

/**
 * @author haustsusu
 * @create 2023-03-05-23:04
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {

    private DictMapper dictMapper;
    public DictListener(DictMapper dictMapper){
        this.dictMapper=dictMapper;
    }


    //一行一行的读取
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {

        //将dictEeVo放入到dict,插入数据库
        Dict dict=new Dict();
        BeanUtils.copyProperties(dictEeVo,dict);
        dictMapper.insert(dict);

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
